﻿using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace FlyRemote.Remote
{


    public class ScanSettin : INotifyPropertyChanged
    {



        public event PropertyChangedEventHandler PropertyChanged;
        public void DoNotify([CallerMemberName] string propName = "")
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
        }



        #region 主要


        private ulong startAddress;
        public ulong StartAddress
        {
            get => startAddress;
            set { startAddress = value; DoNotify(); }
        }



        private ulong endAddress;
        public ulong EndAddress
        {
            get => endAddress;
            set { endAddress = value; DoNotify(); }
        }

        public bool IsUserMode { get; set; } = true;


        private int alignment = 4;
        public int Alignment { get => alignment; set { alignment = value; DoNotify(); } }


        #endregion

        //冻结时间间隔
        public int FreezeInterval { get; set; } = 100;


        // 重新扫描时间间隔
        public int RescanInterval { get; set; } = 100;

        // 读取结果时间间隔
        public int ResultReadInterval { get; set; } = 100;

        // 表读取时间间隔
        public int TableReadInterval { get; set; } = 100;

        public int InputCorrelatorTimeOutInterval
        {
            get; set;
        }


        #region 内存类型
        public bool MemoryTypeNone { get; set; } = true;

        public bool MemoryTypePrivate { get; set; } = true;


        public bool MemoryTypeImage { get; set; } = true;

        public bool MemoryTypeMapped { get; set; } = false;



        #endregion





        #region 内存权限 

        private bool requiredWrite = true;
        public bool RequiredWrite
        {
            get => requiredWrite;
            set { requiredWrite = value; DoNotify(); }
        }

        private bool requiredExecute = false;
        public bool RequiredExecute
        {
            get => requiredExecute;
            set { requiredExecute = value; DoNotify(); }
        }


        private bool requiredCopyOnWrite;
        public bool RequiredCopyOnWrite
        {
            get => requiredCopyOnWrite;
            set { requiredCopyOnWrite = value; DoNotify(); }
        }


        private bool excludedWrite;
        public bool ExcludedWrite
        {
            get => excludedWrite;
            set { excludedWrite = value; DoNotify(); }
        }

        private bool excludedExecute;
        public bool ExcludedExecute
        {
            get => excludedExecute;
            set { excludedExecute = value; DoNotify(); }
        }

        private bool excludedCopyOnWrite;
        public bool ExcludedCopyOnWrite
        {
            get => excludedCopyOnWrite;
            set { excludedCopyOnWrite = value; DoNotify(); }
        }


        #endregion

    }


    public static class ScanSettings
    {


        private static ScanSettin auto = new ScanSettin();

        private static ScanSettin manual = new ScanSettin();

        private static ScanSettin _default;

        public static ScanSettin Default
        {
            get
            {
                if (_default == null)
                    _default = auto;
                return _default;
            }
        }

        public static ScanSettin Manual
        {
            get
            {
                return manual;
            }
        }

        public static void SetToAuto()
        {
            _default = auto;
        }

        public static void SetToManual()
        {
            _default = manual;
        }
    }
}
